package com.srd.phone.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shengrongdai.srd.R;
import com.srd.phone.bean.ChildData;
import com.srd.phone.utils.views.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class AwardIntegralAdapter extends BaseAdapter {

    private Context context;
    private List<ChildData> mList = new ArrayList<>(10);

    public AwardIntegralAdapter(Context context, List<ChildData> list) {
        this.context = context;
        this.mList = list;
    }

    public void setData(List<ChildData> list) {
        this.mList = list;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public ChildData getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {

        ViewHolder viewHolder =  ViewHolder.get(context, view, parent, R.layout.item_integral_layout, position);
        ChildData item = getItem(position);
        TextView tv_title = (TextView)viewHolder.getView(R.id.tv_title);
        tv_title.setText(item.reason);

        TextView tv_integral = (TextView)viewHolder.getView(R.id.tv_integral);
        tv_integral.setText(item.integral + "分");

        TextView tv_date = (TextView)viewHolder.getView(R.id.tv_date);
        tv_date.setText(item.ctime);

        return viewHolder.getConvertView();
    }


}
